package com.byzx.wine.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.byzx.wine.dao.SyuserMapper;
import com.byzx.wine.jdbcdao.UserDao;

import com.byzx.wine.po.Syuser;
import com.byzx.wine.service.ISyuserService;
import com.byzx.wine.util.Page;

@Service
public class SyuserService implements ISyuserService {
	@Autowired
	private UserDao userDao;

	@Autowired
	private SyuserMapper syuserMapper;

	@Override
	public int deleteByPrimaryKey(Integer id) {

		return syuserMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int insert(Syuser record) {

		return syuserMapper.insert(record);
	}

	@Override
	public boolean deleteAll(String ids) {
		try {
			String[] users = ids.split(",");
			for (int i = 0; i < users.length; i++) {

				int id = Integer.parseInt(users[i]);
				syuserMapper.deleteByPrimaryKey(id);
			}
			return true;
		} catch (Exception e) {
			return false;
		}
	}

	@Override
	public int updateByPrimaryKey(Syuser record) {
		// TODO Auto-generated method stub
		return syuserMapper.updateByPrimaryKey(record);
	}

	@Override
	public Page<Map<String, Object>> findPage(Page<Map<String, Object>> page) {
		String sqlid = "com.byzx.wine.jdbcdao.UserDao.SelectAll";
		return userDao.findPage(sqlid, page);
	}



	@Override
	public Syuser selectOne(String name) {

		return userDao.selectOne(name);
	}

	@Override
	public Syuser selectByPrimaryKey(Integer id) {
		
		return syuserMapper.selectByPrimaryKey(id);
	}


}
